import urllib, json

def geocode_address(address):
    query = urllib.urlencode({
        'q': address,
        'output': 'json',
    })
    
    geofile = urllib.urlopen('http://maps.google.com/maps/geo?%s' % query)
    geodata = json.read(geofile.read())
    
    if geodata['Status']['code'] != 200:
        return 0,0
    
    coord = geodata['Placemark'][0]['Point']['coordinates']
    
    return (coord[1], coord[0])